package com.example.demo2;

import net.dongliu.apk.parser.ApkFile;
import net.dongliu.apk.parser.bean.ApkMeta;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class ApkParse {
    public static void main(String[] args) {
        try {
            ApkFile apkFile = new ApkFile(new File("C:\\Users\\DELL\\Desktop\\testAPK.apk"));
            ApkMeta apkMeta = apkFile.getApkMeta();
            System.out.println(apkMeta.getIcon());
            System.out.println(apkMeta.getLabel());
            System.out.println(apkMeta.getPackageName());
            System.out.println(apkMeta.getName());
            System.out.println(apkMeta.getVersionName());
            System.out.println(apkMeta.getVersionCode());
            /*byte[] incons = apkFile.getFileData(apkMeta.getIcon());
            ByteArrayInputStream is = new ByteArrayInputStream(incons);
            String icon = apkMeta.getIcon();
            String iconName = icon.substring(icon.lastIndexOf("/")+1);
            //File file =  new File("F:\\"+iconName);
            //if (!file.exists()) file.mkdirs();
            FileOutputStream fileOutputStream = new FileOutputStream("F:\\"+iconName);
            byte[] bytes = new byte[1024];
            int length;
            while ((length = is.read(bytes))>0){
                fileOutputStream.write(bytes,0,length);
            }*/
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
